#include "Components/KineticsComponent.hpp"
#include "Components/ICompositor.hpp"
#include "Components/IComponent.hpp"
#include "Components/Message.hpp"
#include "Math/Vector.hpp"

namespace Components
{
	KineticsComponent::KineticsComponent( ICompositor &comp )
		: compositor( comp ), dirty( false ), ang( 0.0f ), angVel( 0.0f )
	{
	}
	
	KineticsComponent::~KineticsComponent( void )
	{
	}

	void KineticsComponent::Update( void )
	{
		if ( dirty )
		{
			dirty = false;
			compositor.SendMessage( *this, Message( "Kinetics:Update", 0 ) );
		}
	}

	void KineticsComponent::SetAngle( const float setAng )
	{
		ang = setAng;
	}

	float KineticsComponent::GetAngle( void ) const
	{
		return ang;
	}

	void KineticsComponent::SetPosition( const Math::Vectorf &setPos )
	{
		pos = setPos;
	}

	Math::Vectorf KineticsComponent::GetPosition( void ) const
	{
		return pos;
	}

	void KineticsComponent::SetAngularVelocity( const float setAngVel )
	{
		angVel = setAngVel;
	}

	float KineticsComponent::GetAngularVelocity( void ) const
	{
		return angVel;
	}

	void KineticsComponent::SetLinearVelocity( const Math::Vectorf &setVel )
	{
		vel = setVel;
	}

	Math::Vectorf KineticsComponent::GetLinearVelocity( void ) const
	{
		return vel;
	}
}